import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//注意：首页下的路由需要归类到首页的children中,否则目录无法显示选中状态

const routes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/wrapper',
        component: resolve => require(['../views/wrapper/index.vue'], resolve),
        children: [
            {
                path: '/',
                redirect: '/home',
            },
            //首页
            {
                path: '/home',
                component: resolve => require(['../views/home/index.vue'], resolve)
            },
            //相关案例
            {
                path: '/case',
                component: resolve => require(['../views/case/index.vue'], resolve)
            },
            //产品服务
            {
                path: '/service',
                component: resolve => require(['../views/service/index.vue'], resolve)
            },
            //联系我们
            {
                path: '/contact',
                component: resolve => require(['../views/contact/index.vue'], resolve)
            },
        ]
    }
]

//cv以下代码解决路由地址重复的报错问题
// const originalPush = VueRouter.prototype.push
//    VueRouter.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }

const router = new VueRouter({
  scrollBehavior: () => ({ y: 0 }),
  routes,
  base: '/hzOffice/',
  mode: 'history'
})

export default router


